﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" 
    Inherits="System.Web.Mvc.ViewPage<DCHealthCheck.MvcWeb.Classes.ViewModels.ProcessInfoViewModel>" %>
<%@ Import Namespace="DCHealthCheck.MvcWeb.Classes" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="DCHealthCheck.DomainModel" %>
<%@ Import Namespace="DCHealthCheck.Common" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:Global.ApplicationName%>::<%:"ProcessDetails"%>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="infobox" style="height: auto">
        <label>
            Domain Controller:
        </label>
        <span>
            <%:Model.SelectedProcessInfo.SystemInfo.DomainController.SamAccountNameFriendly%></span> &nbsp;&nbsp;&nbsp;
        
        <label>
            Date:
        </label>
        
        <span>
            <%:Model.SelectedProcessInfo.SystemInfo.CheckDateTimeUTC.LongDateFriendly()%>
        </span>
    </div>
    <div id="contents">
        <div id="leftcontainer" style="width: 500px;">
            <h3>
                Process Information</h3>
            <div>
                <p>
                    <label for="model.ProcessId">
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ProcessId)%>:&nbsp;&nbsp;
                    </label>
                    <%: Html.DisplayFor(model => model.SelectedProcessInfo.ProcessId)%>
                </p>
                <p>
                    <label for="model.ExecutablePath">
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ExecutablePath)%>:&nbsp;&nbsp;
                    </label>
                    <%: Html.DisplayFor(model => model.SelectedProcessInfo.ExecutablePath)%>
                </p>
                <p>
                    <label>
                        Service(s):&nbsp;&nbsp;
                    </label>
                    <% var associatedServices = Model.SelectedProcessInfo.SystemInfo.ServiceInfos.Where(x => x.ProcessId == Model.SelectedProcessInfo.ProcessId).ToList();
                        if (associatedServices.Count > 0) 
                        {
                            var serviceInfo = new List<string>();
                            foreach (var service in associatedServices)
                            {
                                serviceInfo.Add(string.Format("{0} ({1})", service.DisplayName, service.Name));
                            } %>
                        <%:serviceInfo.ToDelimitedString() %>
                        <%} else {%>
                            N/A
                    <%} %>
                </p>
            </div>
            <h3>
                Date and Time Information</h3>
            <div>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.StartDateTime)%>:&nbsp;&nbsp;
                    </label>
                    <%: Model.SelectedProcessInfo.StartDateTime.LongDateFriendly()%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ProcessorTime)%>:&nbsp;&nbsp;
                    </label>
                    <%: Model.SelectedProcessInfo.ProcessorTime.DHMSFriendly()%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ElapsedTime)%>:&nbsp;&nbsp;
                    </label>
                    <%: Html.DisplayFor(model => model.SelectedProcessInfo.ElapsedTime)%>
                </p>
            </div>
            <h3>
                Resources</h3>
            <div>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.HandleCount)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.HandleCount)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ThreadCount)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.ThreadCount)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.NonPagePoolBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.NonPagePoolBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.PagePoolBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.PagePoolBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.PageFaults)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.PageFaults)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.VirtualMemoryBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%: string.Format("{0:n0}", Model.SelectedProcessInfo.VirtualMemoryBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.PrivateBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.PrivateBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.ReadBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.ReadBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.WriteBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.WriteBytes)%>
                </p>
                <p>
                    <label>
                        <%: Html.DisplayNameFor(model => model.SelectedProcessInfo.OtherBytes)%>:&nbsp;&nbsp;
                    </label>
                    <%:string.Format("{0:n0}", Model.SelectedProcessInfo.OtherBytes)%>
                </p>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptsSection" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#leftcontainer").accordion({
                active: 0,
                heightStyle: "content",
                collapsible: true
            });
        });
    </script>
</asp:Content>
